package Acwing.基础算法;

import java.util.Scanner;

/**
 * @Title: determineSubsequence
 * @Author 贾金博
 * @Package Acwing.基础算法
 * @Date 2025/4/10 上午10:56
 * @description: 判断子序列问题
 */
public class determineSubsequence {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n, m;
        n = sc.nextInt();
        m = sc.nextInt();
        int[] a = new int[n + 10];
        int[] b = new int[m + 10];
        for(int i = 1; i <= n; i ++ ) {
            a[i] = sc.nextInt();
        }

        for(int j = 1; j <= m; j ++ ) {
            b[j] = sc.nextInt();
        }

        // 现在开始判断是不是子序列
        // 在数组b里面去判断a是不是它的子序列
        int i = 1;
        for(int j = 1; j <= m; j ++ ) {
            while(a[i] == b[j] && i <= n && j <= m) {
                i ++ ;
                if(i == n + 1) {
                    break;
                }
                j ++ ;
            }
        }
        if(i == n + 1) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}
